package com.millstein.baier.controller;

import com.millstein.baier.model.dto.QuestionRecordDto;
import com.millstein.baier.model.result.Result;
import com.millstein.baier.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("upload")
@CrossOrigin
public class UploadController {

    @Autowired
    private UploadService uploadService;

    /**
     * 上传图片并提交反馈
     * @param files 图片的数组
     * @param dto 问题提交的其他数据
     * @return
     */
    @PostMapping
    public Result submit(@RequestParam("file") List<MultipartFile> files, QuestionRecordDto dto) {
        uploadService.upload(files, dto);
        return Result.ok();
    }
}
